#!/bin/sh

# Slackware build script for artwiz-aleczapka
# Written by Kyle Guinn <elyk03@gmail.com>

set -e

# To make a package for fonts other than English, run the script as, for
# example, "FONTLANG=de ./artwiz-aleczapka.SlackBuild".  You will need to
# download the correct tarball and place it in this directory.  See the
# SourceForge download page for the available tarballs.
FONTLANG=${FONTLANG:-en}

PRGNAM=artwiz-aleczapka-$FONTLANG
VERSION=1.3
ARCH=noarch
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.bz2
cd $PRGNAM-$VERSION
chown -R root:root .
chmod -R u+w,go+r-w,a-s .

# The English package contains a cursor font.  To avoid clobbering the
# existing one (from the x/font-cursor-misc package), rename it.
# TODO:  Figure out and document how to set the default cursor font.
if [ -e cursor.pcf ]; then
  mv cursor.pcf artwiz-cursor.pcf
fi

gzip -9 *.pcf
mkdir -p $PKG/usr/share/fonts/misc
cp -a *.pcf.gz $PKG/usr/share/fonts/misc

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a AUTHORS COPYING ChangeLog NEWS README* \
  $PKG/usr/doc/$PRGNAM-$VERSION || true
cat $CWD/artwiz-aleczapka.SlackBuild > \
  $PKG/usr/doc/$PRGNAM-$VERSION/artwiz-aleczapka.SlackBuild

mkdir -p $PKG/install
# Fix the package name in the slack-desc file
sed s/FONTLANG/$FONTLANG/g $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}
